cd C:\Users\chausman\Dropbox\Legacy_utility_costs\Data_package_to_post
 
use data/cpi/cpi, clear
sum cpi if year==2019
global cpi2019=r(mean)

/*
portion_resi_sales>=.9 //mostly bundled customers

abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 //no mergers and acquisitions
regime_length>=2 //thought experiment multi-year growth/loss; and minimize measurement error from timing and blips

minmmiles>=20 //not too much measurement error in log miles
abs(dlnmmiles)<=1 //outliers in miles

abs(dln`v'_nr1)<2 //outliers in net revenue change
resi_nr1>0 //outliers in net revenue
resi_nrpc1<350*10 //an order of magnitude larger than the median
resi_nrpq1<6*10 //an order of magnitude larger than the median
comm_nr1>0 //outliers in net revenue
comm_nrpc1<1300*10
comm_nrpq1<5*10
*/

///////////////////	
//REGRESSION TABLE: MILES
use data/legacy_utility_data_controls, clear
bysort id: egen minmmiles=min(mmiles)
xtset id year 
gen dlnresi_cust1=d.lnresi_cust1
	compare dlnresi_cust1 dlnresi_grow1 if resi_dummy_grow_1==1
	compare dlnresi_cust1 dlnresi_shrink1 if resi_dummy_grow_1==0
gen dlncomm_cust1=d.lncomm_cust1
	compare dlncomm_cust1 dlncomm_grow1 if comm_dummy_grow_1==1
	compare dlncomm_cust1 dlncomm_shrink1 if comm_dummy_grow_1==0
gen resi_flat=0
	replace resi_flat=1 if resi_cust1==l.resi_cust1
	replace resi_dummy_grow_1=0 if resi_flat==1 & resi_dummy_grow_1!=. //not needed
gen comm_flat=0
	replace comm_flat=1 if comm_cust1==l.comm_cust1
	replace comm_dummy_grow_1=0 if comm_flat==1 & comm_dummy_grow_1!=.
label variable dlnresi_cust1 "Residential customers (log)"
label variable dlnresi_grow1 "Residential customers (log), when growing"
label variable dlnresi_shrink1 "Residential customers (log), when shrinking"
label variable dlncomm_cust1 "Commercial customers (log)"
label variable dlncomm_grow1 "Commercial customers (log), when growing"
label variable dlncomm_shrink1 "Commercial customers (log), when shrinking"
label variable resi_dummy_grow_1 "Dummy, residential growth"
label variable comm_dummy_grow_1 "Dummy, commercial growth"
label variable resi_flat "Dummy, residential customers flat"
label variable comm_flat "Dummy, commercial customers flat" //not using -- currently growth dummy==0, which is what we want for interpretation so this isn't needed
reg dlnmmiles ///
	dlnresi_cust1 ///
	dlncomm_cust1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	, cluster(id) 
	quietly sum mmiles if e(sample), detail
		local temp1=r(p50)
	quietly sum resi_cust1 if e(sample), detail
		local temp2=r(p50)	
	quietly sum comm_cust1 if e(sample), detail
		local temp3=r(p50)
	//median:
	lincom dlnresi_cust1 * `temp1' / (`temp2'/100)
	estadd scalar naiveresi=r(estimate)
	lincom dlncomm_cust1 * `temp1' / (`temp3'/100)
	estadd scalar naivecomm=r(estimate)
	estimates store v1
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	, cluster(id) 
	test dlnresi_grow1 = dlnresi_shrink1
		estadd scalar resi=r(p)
	test dlncomm_grow1 = dlncomm_shrink1
		estadd scalar comm=r(p)
	test dlnresi_grow1 +dlncomm_grow1 = dlnresi_shrink1+ dlncomm_shrink1
		estadd scalar combined=r(p)
	quietly sum mmiles if e(sample), detail
		local temp1=r(p50)
	quietly sum resi_cust1 if e(sample), detail
		local temp5=r(p50)	
	quietly sum comm_cust1 if e(sample), detail
		local temp6=r(p50)
	//median:	
	lincom dlnresi_grow1 * `temp1' / (`temp5'/100)
	estadd scalar grow=r(estimate)
	lincom dlnresi_shrink1 * `temp1' / (`temp5'/100)
	estadd scalar shrink=r(estimate)
	lincom dlncomm_grow1 * `temp1' / (`temp6'/100)
	lincom dlncomm_shrink1 * `temp1' / (`temp6'/100)
	estimates store v2
	unique id if e(sample)
	disp e(N)/(2019-1997)
	lincom dlnresi_grow1-1
	lincom dlnresi_grow1-0.249
esttab v1 v2  ///
	using asymmetrymiles.tex, replace fragment ///
 	cells(b(fmt(%12.3f) star) se(par fmt(%12.3f)))	///
	stats(N r2 naiveresi grow shrink resi comm combined  , fmt(%9.0fc %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f) ///
		labels("Observations" "R$^{2}$" "\\ \hline \\  Miles per 100 residential customers" "\hspace{.2in} When growing" "\hspace{.2in} When shrinking" "P-value: null of symmetry \\ \hspace{.2in} Residential" "\hspace{.2in} Commercial" "\hspace{.2in} Combined" ))	///
	keep(dlnresi_cust1 dlncomm_cust1 dlnresi_grow1 dlnresi_shrink1 dlncomm_grow1 dlncomm_shrink1  _cons) ///
	order(dlnresi_cust1 dlncomm_cust1 dlnresi_grow1 dlnresi_shrink1 dlncomm_grow1 dlncomm_shrink1  _cons) ///
	mlabel("Pipeline Miles (log)" "Pipeline Miles (log)") ///
	label lz varwidth(16) modelwidth(13) style(tex) ///
	posthead("\\ \hline \\") prefoot("\\ \hline \\") ///
	collabels(,none) /*nonumbers*/	///
	coeflabels(_cons "Constant") /// 
	starlevels(* 0.1 ** 0.05 *** 0.01)
		
//APPENDIX: ALTERNATIVE SPECIFICATIONS AND SUBSAMPLES
//original
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	, cluster(id) 
	estimates store v1
//including customer choice
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if /*portion_resi_sales>=.9*/ ///
	/*&*/ abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	, cluster(id)  
	estimates store v2
//including service territory changes
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	/*& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5*/ ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	, cluster(id) 
	estimates store v3
//including one-year regimes
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	/*& regime_length>=2*/ ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	, cluster(id) 
	estimates store v4
//including small miles
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	/*& minmmiles>=20*/ & abs(dlnmmiles)<=1 ///
	, cluster(id) 
	estimates store v5
//including changes outliers
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 /*& abs(dlnmmiles)<=1*/ ///
	, cluster(id) 
	estimates store v6
//including all raw data
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	, cluster(id) 
	estimates store v7
//more stringent LHS outliers
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=.5 ///
	, cluster(id) 
	estimates store v8
//ious
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	& iou==1, cluster(id)  
	estimates store v9
//only on 10,000+ customers
bysort idnojumps: egen size=min(resi_cust1)
xtset id year
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	& size>=10000, cluster(id)
	estimates store v10
//additional controls
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	d.hdd d.cdd d.lnresi_qpc1 d.lncomm_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	, cluster(id) 
	estimates store v11
//year effects
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	i.year ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	, cluster(id) 
	estimates store v12
//fixed effects, in differences (like trends)
areg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	, absorb(id) cluster(id) 
	estimates store v13
	
//medium run
foreach v in mmiles resi_cust1 comm_cust1{
	gen d3ln`v'=ln`v'-l3.ln`v'
}
foreach v in resi comm{
gen d3_`v'_dummy_grow_1=1 if d3ln`v'_cust1>=0
	replace d3_`v'_dummy_grow_1=0 if d3ln`v'_cust1<0
	replace d3_`v'_dummy_grow_1=. if d3ln`v'_cust1==.
}	
foreach v in resi comm{
	gen d3ln`v'_grow1=d3ln`v'_cust1 * d3_`v'_dummy_grow_1
	gen d3ln`v'_shrink1=d3ln`v'_cust1 * (1-d3_`v'_dummy_grow_1 )
}
foreach v in dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1{	
	//so they show up in the same line of the table
	rename `v' `v'temp
}
	gen dlnresi_grow1 =d3lnresi_grow1
	gen dlnresi_shrink1 =d3lnresi_shrink1
	gen resi_dummy_grow_1 =d3_resi_dummy_grow_1
	gen dlncomm_grow1 =d3lncomm_grow1
	gen dlncomm_shrink1 =d3lncomm_shrink1
	gen comm_dummy_grow_1 =d3_comm_dummy_grow_1
reg d3lnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=4 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	, cluster(id)
	estimates store v14
	foreach v in dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1{	
		drop `v'
		rename `v'temp `v'
		//DO NOT DELETE THIS LINE
	}
	
label variable dlnresi_grow1 "Resi. cust. (log), growing"
label variable dlnresi_shrink1 "Resi. cust. (log), shrinking"
label variable dlncomm_grow1 "Comm. cust. (log), growing"
label variable dlncomm_shrink1 "Comm. cust. (log), shrinking"	
esttab v1 v2 v3 v4 v5 v6 v7 ///
	using asymmetrymilesappendixA.tex, replace fragment ///
 	cells(b(fmt(%12.2f) star) se(par fmt(%12.2f)))	///
	stats(N r2, fmt(%9.0fc %9.2f) ///
		labels("Observations" "R$^{2}$"))	///
	keep(dlnresi_grow1 dlnresi_shrink1 dlncomm_grow1 dlncomm_shrink1)	///
	mlabel(,none) ///
	label lz varwidth(16) modelwidth(13) style(tex) ///
	posthead("\\ \hline \\") prefoot("\\ \hline \\") ///
	collabels(,none) /*nonumbers*/	///
	nocons ///
	starlevels(* 0.1 ** 0.05 *** 0.01)
esttab  v8 v9 v10 v11 v12 v13 v14 ///
	using asymmetrymilesappendixB.tex, replace fragment ///
 	cells(b(fmt(%12.2f) star) se(par fmt(%12.2f)))	///
	stats(N r2, fmt(%9.0fc %9.2f) ///
		labels("Observations" "R$^{2}$"))	///
	keep(dlnresi_grow1 dlnresi_shrink1 dlncomm_grow1 dlncomm_shrink1)	///
	mlabel(,none) ///
	label lz varwidth(16) modelwidth(13) style(tex) ///
	posthead("\\ \hline \\") prefoot("\\ \hline \\") ///
	collabels(, none) nonumbers	///
	nocons ///
	starlevels(* 0.1 ** 0.05 *** 0.01)



//APPENDIX: INCLUDING VERY SMALL UTILITIES
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	/*& minmmiles>=20*/ & abs(dlnmmiles)<=1 ///
	, cluster(id)
	estimates store v0
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=10 & abs(dlnmmiles)<=1 ///
	, cluster(id)
	estimates store v1
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 ///
	, cluster(id) 
	estimates store v2
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=30 & abs(dlnmmiles)<=1 ///
	, cluster(id)
	estimates store v3
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=40 & abs(dlnmmiles)<=1 ///
	, cluster(id)
	estimates store v4
esttab v0 v1 v2 v3 v4  ///
	using asymmetrymilesminmiles.tex, replace fragment ///
 	cells(b(fmt(%12.2f) star) se(par fmt(%12.2f)))	///
	stats(N r2, fmt(%9.0fc %9.2f) ///
		labels("Observations" "R$^{2}$"))	///
	keep(dlnresi_grow1 dlnresi_shrink1 dlncomm_grow1 dlncomm_shrink1)	///
	mlabel("All" "10+ miles" "20+ miles" "30+ miles" "40+ miles" "50+ miles" "60+ miles" "70+ miles") ///
	label lz varwidth(16) modelwidth(13) style(tex) ///
	posthead("\\ \hline \\") prefoot("\\ \hline \\") ///
	collabels(,none) nonumbers	///
	nocons ///
	starlevels(* 0.1 ** 0.05 *** 0.01)
	
	
	
//////////////////////
//REGRESSION TABLE: NET REVENUE	
use data/legacy_utility_data_controls, clear
xtset id year 
gen dlnresi_cust1=d.lnresi_cust1
	compare dlnresi_cust1 dlnresi_grow1 if resi_dummy_grow_1==1
	compare dlnresi_cust1 dlnresi_shrink1 if resi_dummy_grow_1==0
gen dlncomm_cust1=d.lncomm_cust1
	compare dlncomm_cust1 dlncomm_grow1 if comm_dummy_grow_1==1
	compare dlncomm_cust1 dlncomm_shrink1 if comm_dummy_grow_1==0
label variable dlnresi_cust1 "Residential customers (log)"
label variable dlncomm_cust1 "Commercial customers (log)"
label variable dlnresi_grow1 "Residential customers (log), when growing"
label variable dlnresi_shrink1 "Residential customers (log), when shrinking"
label variable dlncomm_grow1 "Commercial customers (log), when growing"
label variable dlncomm_shrink1 "Commercial customers (log), when shrinking"

foreach v in resi comm{
	gen count=dln`v'_cust1
	gen grow=dln`v'_grow1
	gen shrink=dln`v'_shrink1
	local resi_nrpc1limit =350*10
	local resi_nrpq1limit =6*10
	local comm_nrpc1limit =1300*10
	local comm_nrpq1limit =5*10
	
reg dln`v'_nr1 ///
	count ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	quietly sum `v'_nr1 if e(sample), detail
		local temp1=r(p50)
	quietly sum `v'_cust1 if e(sample), detail
		local temp5=r(p50)		
	//median:	
	lincom count * `temp1' / (`temp5'/1)
	estadd scalar naive=r(estimate)
	estimates store vcount`v'
	
reg dln`v'_nr1 ///
	grow shrink `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	test grow = shrink
		estadd scalar diff=r(p)
	quietly sum `v'_nr1 if e(sample), detail
		local temp1=r(p50)
	quietly sum `v'_cust1 if e(sample), detail
		local temp5=r(p50)		
	//median:	
	lincom grow * `temp1' / (`temp5'/1)
	estadd scalar grow=r(estimate)
	lincom shrink * `temp1' / (`temp5'/1)
	estadd scalar shrink=r(estimate)
	estimates store vasym`v'
	drop count grow shrink
}
esttab vcountresi vcountcomm vasymresi vasymcomm ///
	using asymmetrynr.tex, replace fragment ///
 	cells(b(fmt(%12.2f) star) se(par fmt(%12.2f)))	///
	stats(N r2 naive grow shrink diff , fmt(%9.0fc %9.2f %9.0f %9.0f %9.0f %9.2f  ) ///
	labels("Observations" "R$^{2}$" "\\ \hline \\  Dollars per customer" "\hspace{.2in} When growing" "\hspace{.2in} When shrinking" "P-value: null of symmetry" ))	///
	keep(count grow shrink _cons)	///
	order(count grow shrink _cons) ///
	mlabel(" \makecell[c]{Residential \\ Net Revenue} " " \makecell[c]{Commercial \\ Net Revenue} " " \makecell[c]{Residential \\ Net Revenue} " " \makecell[c]{Commercial \\ Net Revenue} ") ///
	label lz varwidth(16) modelwidth(13) style(tex) ///
	posthead("\\ \hline \\") prefoot("\\ \hline \\") ///
	collabels(,none) /*nonumbers*/	///
	coeflabels(_cons "Constant" count "Customers (log)" grow  "Customers (log), when growing" shrink "Customers (log), when shrinking") ///
	starlevels(* 0.1 ** 0.05 *** 0.01)

esttab vcountresi vcountcomm vasymresi vasymcomm ///
	using asymmetrynrallcoeffs.tex, replace fragment ///
 	cells(b(fmt(%12.2f) star) se(par fmt(%12.2f)))	///
	stats(N r2  , fmt(%9.0fc %9.2f   ) ///
	labels("Observations" "R$^{2}$" "\\ \hline \\  Dollars per customer" "\hspace{.2in} When growing" "\hspace{.2in} When shrinking" "P-value: null of symmetry" ))	///
	order(count grow shrink ) ///
	mlabel("Residential" "Commercial" "Residential" "Commercial") ///
	label lz varwidth(16) modelwidth(13) style(tex) ///
	posthead("\\ \hline \\") prefoot("\\ \hline \\") ///
	collabels(,none) nonumbers	///
	coeflabels(_cons "Constant" count "Customers (log)" grow  "Customers (log), when growing" shrink "Customers (log), when shrinking") ///
	starlevels(* 0.1 ** 0.05 *** 0.01)	
	
//APPENDIX: ALTERNATIVE SPECIFICATIONS AND SUBSAMPLES
foreach v in resi comm{
	local resi_nrpc1limit =350*10
	local resi_nrpq1limit =6*10
	local comm_nrpc1limit =1300*10
	local comm_nrpq1limit =5*10
xtset id year
//original
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	estimates store v1
//including customer choice
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if /*portion_resi_sales>=.9*/ ///
	/*&*/ abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	estimates store v2
//including service territory changes
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	/*& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5*/ ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	estimates store v3
//including one-year regimes
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	/*& regime_length>=2*/ ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	estimates store v4
//keeping LHS outliers
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	/*& abs(dln`v'_nr1)<2*/ ///
	/*& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit'*/ ///
	, cluster(id)
	estimates store v5	
//including all raw data
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	, cluster(id)
	estimates store v6
//more stringent LHS outliers
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<1 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	estimates store v7	
//ious
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	& iou==1, cluster(id)
	estimates store v8
//only on 10,000+ customers
bysort idnojumps: egen size=min(resi_cust1)
xtset id year
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	& size>=10000, cluster(id)
	drop size
	estimates store v9	
//no controls
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	/*d.hdd d.cdd d.ln`v'_qpc1*/ ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	estimates store v10
//year effects
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	i.year ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	estimates store v11
//fixed effects
areg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, absorb(id) cluster(id)
	estimates store v12
//reports miles
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	& mmiles!=., cluster(id)
	estimates store v13
//including resi and comm on RHS	
reg dln`v'_nr1 ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	estimates store v14
//version 2 of the variables
foreach x in dln`v'_nr dln`v'_grow dln`v'_shrink `v'_dummy_grow_{
	rename `x'1 `x'1temp
}
foreach x in dln`v'_nr dln`v'_grow dln`v'_shrink `v'_dummy_grow_{
	gen `x'1=`x'2
}
reg dln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc2 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust2)<.2 & abs(d.lncomm_cust2)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr2)<2 ///
	& `v'_nrpc2<``v'_nrpc1limit' & `v'_nrpq2<``v'_nrpq1limit' ///
	, cluster(id)
	estimates store v15
foreach x in dln`v'_nr dln`v'_grow dln`v'_shrink `v'_dummy_grow_{
	drop `x'1 
	rename `x'1temp `x'1 //DO NOT DELETE THIS LINE
}
//different citygate
gen `v'_nr1_temp=`v'_total_volume * (`v'_sales_price_real - citygate_alt_wt`v'_real)
xtset id year
gen ln`v'_nr1_temp=ln(`v'_nr1_temp)
gen dln`v'_nr1_temp=d.ln`v'_nr1_temp
reg dln`v'_nr1_temp ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1_temp)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	estimates store v16
drop `v'_nr1_temp ln`v'_nr1_temp dln`v'_nr1_temp	
//long differences
xtset idnojumps year
	gen d3ln`v'_cust1=ln`v'_cust1-l3.ln`v'_cust1
	gen d3_`v'_dummy_grow_1=1 if d3ln`v'_cust1>=0
	replace d3_`v'_dummy_grow_1=0 if d3ln`v'_cust1<0
	replace d3_`v'_dummy_grow_1=. if d3ln`v'_cust1==.
	gen d3ln`v'_grow1=d3ln`v'_cust1 * d3_`v'_dummy_grow_1
	gen d3ln`v'_shrink1=d3ln`v'_cust1 * (1-d3_`v'_dummy_grow_1 )
	gen d3hdd=hdd-l3.hdd
	gen d3cdd=cdd-l3.cdd
	gen d3ln`v'_nr1=ln`v'_nr1-l3.ln`v'_nr1
	gen d3ln`v'_qpc1=ln`v'_qpc1-l3.ln`v'_qpc1

foreach x in dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 {	
	//so they show up in the same line of the table
	rename `x' `x'temp
}
	gen dln`v'_grow1 =d3ln`v'_grow1
	gen dln`v'_shrink1 =d3ln`v'_shrink1
	gen `v'_dummy_grow_1 =d3_`v'_dummy_grow_1
	
reg d3ln`v'_nr1 ///
	dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 ///
	d3hdd d3cdd d3ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=4 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	estimates store v17
	drop d3*
	foreach x in dln`v'_grow1 dln`v'_shrink1 `v'_dummy_grow_1 {	
		drop `x'
		rename `x'temp `x'
		//DO NOT DELETE THIS LINE
	}
	
label variable dlnresi_grow1 "Resi. cust. (log), grow"
label variable dlnresi_shrink1 "Resi. cust. (log), shrink"
label variable dlncomm_grow1 "Comm. cust. (log), grow"
label variable dlncomm_shrink1 "Comm. cust. (log), shrink"	

esttab v1 v2 v3 v4 v5 v6 v7 v8 v9   ///
	using asymmetrynr`v'appendixA.tex, replace fragment ///
 	cells(b(fmt(%12.2f) star) se(par fmt(%12.2f)))	///
	stats(N r2, fmt(%9.0fc %9.2f) ///
		labels("Observations" "R$^{2}$"))	///
	keep(dln`v'_grow1 dln`v'_shrink1     )	///
	mlabel(,none) ///
	label lz varwidth(16) modelwidth(13) style(tex) ///
	posthead("\\ \hline \\") prefoot("\\ \hline \\") ///
	collabels(,none) /*nonumbers*/	///
	nocons ///
	starlevels(* 0.1 ** 0.05 *** 0.01)
esttab v10 v11 v12 v13 v14 v15 v16 v17   ///
	using asymmetrynr`v'appendixB.tex, replace fragment ///
 	cells(b(fmt(%12.2f) star) se(par fmt(%12.2f)))	///
	stats(N r2, fmt(%9.0fc %9.2f) ///
		labels("Observations" "R$^{2}$"))	///
	keep(dlnresi_grow1 dlnresi_shrink1 dlncomm_grow1 dlncomm_shrink1   )	///
	mlabel(,none) ///
	label lz varwidth(16) modelwidth(13) style(tex) ///
	posthead("\\ \hline \\") prefoot("\\ \hline \\") ///
	collabels(,none) nonumbers	///
	nocons ///
	starlevels(* 0.1 ** 0.05 *** 0.01)
}	
	
	
	
//////////////////////
//APPENDIX REGRESSION TABLES: NET REVENUE PER CUSTOMER, QUANTITY PER CUSTOMER
use data/legacy_utility_data_controls, clear
xtset id year 
label variable dlnresi_grow1 "Residential customers (log), when growing"
label variable dlnresi_shrink1 "Residential customers (log), when shrinking"
label variable dlncomm_grow1 "Commercial customers (log), when growing"
label variable dlncomm_shrink1 "Commercial customers (log), when shrinking"

foreach v in resi comm{
	gen grow=dln`v'_grow1
	gen shrink=dln`v'_shrink1
	local resi_nrpc1limit =350*10
	local resi_nrpq1limit =6*10
	local comm_nrpc1limit =1300*10
	local comm_nrpq1limit =5*10
	
reg dln`v'_nrpc1 ///
	grow shrink `v'_dummy_grow_1 ///
	d.hdd d.cdd d.ln`v'_qpc1 ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id) 
	test grow = shrink
		estadd scalar diff=r(p)
	quietly sum `v'_nrpc1 if e(sample), detail
		local temp1=r(p50)
	quietly sum `v'_cust1 if e(sample), detail
		local temp5=r(p50)		
	//median:	
	lincom grow * `temp1' / (`temp5'/1)
	estadd scalar grow=r(estimate)
	lincom shrink * `temp1' / (`temp5'/1)
	estadd scalar shrink=r(estimate)
	estimates store vasym`v'
	drop grow shrink
}
esttab vasymresi vasymcomm ///
	using asymmetrynrpc.tex, replace fragment ///
 	cells(b(fmt(%12.2f) star) se(par fmt(%12.2f)))	///
	stats(N r2 , fmt(%9.0fc %9.2f  ) ///
	labels("Observations" "R$^{2}$" "\\ \hline \\  Average price per customer" "\hspace{.2in} When growing" "\hspace{.2in} When shrinking" "P-value: null of symmetry" ))	///
	keep(grow shrink)	///
	mlabel("Residential" "Commercial" ) ///
	label lz varwidth(16) modelwidth(13) style(tex) ///
	posthead("\\ \hline \\") prefoot("\\ \hline \\") ///
	collabels(,none) nonumbers	///
	nocons ///
	coeflabels(grow  "Customers (log), when growing" shrink "Customers (log), when shrinking") ///
	starlevels(* 0.1 ** 0.05 *** 0.01)


foreach v in resi comm{
	gen grow=dln`v'_grow1
	gen shrink=dln`v'_shrink1
	gen dln`v'_qpc1=d.ln`v'_qpc1
	
reg dln`v'_qpc1 ///
	grow shrink `v'_dummy_grow_1 ///
	d.hdd d.cdd ///
	if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dln`v'_nr1)<2 ///
	& `v'_nrpc1<``v'_nrpc1limit' & `v'_nrpq1<``v'_nrpq1limit' ///
	, cluster(id)
	test grow = shrink
		estadd scalar diff=r(p)
	quietly sum `v'_qpc1 if e(sample), detail
		local temp1=r(p50)
	quietly sum `v'_cust1 if e(sample), detail
		local temp5=r(p50)		
	//median:	
	lincom grow * `temp1' / (`temp5'/1)
	estadd scalar grow=r(estimate)
	lincom shrink * `temp1' / (`temp5'/1)
	estadd scalar shrink=r(estimate)
	estimates store vasym`v'
	drop grow shrink
}
esttab vasymresi vasymcomm ///
	using asymmetryqpc.tex, replace fragment ///
 	cells(b(fmt(%12.2f) star) se(par fmt(%12.2f)))	///
	stats(N r2 , fmt(%9.0fc %9.2f ) ///
	labels("Observations" "R$^{2}$" "\\ \hline \\  Quantity per customer" "\hspace{.2in} When growing" "\hspace{.2in} When shrinking" "P-value: null of symmetry" ))	///
	keep(grow shrink)	///
	mlabel("Residential" "Commercial" ) ///
	label lz varwidth(16) modelwidth(13) style(tex) ///
	posthead("\\ \hline \\") prefoot("\\ \hline \\") ///
	collabels(,none) nonumbers	///
	nocons ///
	coeflabels(grow  "Customers (log), when growing" shrink "Customers (log), when shrinking") ///
	starlevels(* 0.1 ** 0.05 *** 0.01)
	
	
//////////////////////////
//ECM MODELS
use data/legacy_utility_data_controls, clear
bysort id: egen minmmiles=min(mmiles)
xtset id year
	local resi_nrpc1limit =350*10
	local resi_nrpq1limit =6*10
	local comm_nrpc1limit =1300*10
	local comm_nrpq1limit =5*10

keep if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///	
	& minmmiles>=20 & abs(dlnmmiles)<=1 
reg dlnmmiles ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	, cluster(id) 
	estimates store v1
areg lnmmiles ///
	lnresi_grow1 lnresi_shrink1 resi_dummy_grow_1 ///
	lncomm_grow1 lncomm_shrink1 comm_dummy_grow_1 ///
	year, absorb(fe_regime) cluster(id) 
	estimates store v2
xtset fe_regime year
xtpmg d.lnmmiles dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 year, ///
	lr(l.lnmmiles l.lnresi_grow1 l.lnresi_shrink1 l.resi_dummy_grow_1 ///
	l.lncomm_grow1 l.lncomm_shrink1 l.comm_dummy_grow_1 l.year) ///
	replace dfe cluster(id)	
	estimates store v3
	
use data/legacy_utility_data_controls, clear
bysort id: egen minmmiles=min(mmiles)
xtset id year
keep if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dlnresi_nr1)<2 ///
	& resi_nrpc1<`resi_nrpc1limit' & resi_nrpq1<`resi_nrpq1limit' 
reg dlnresi_nr1 ///
	dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	d.hdd d.cdd d.lnresi_qpc1 ///
	, cluster(id) 
	estimates store v4
areg lnresi_nr1 ///
	lnresi_grow1 lnresi_shrink1 resi_dummy_grow_1 ///
	hdd cdd lnresi_qpc1 year ///
	, absorb(fe_regime) cluster(id) 
	estimates store v5
xtset fe_regime year
xtpmg d.lnresi_nr1 dlnresi_grow1 dlnresi_shrink1 resi_dummy_grow_1 ///
	d.hdd d.cdd d.lnresi_qpc1 year, ///
	lr(l.lnresi_nr1 l.lnresi_grow1 l.lnresi_shrink1 l.resi_dummy_grow_1 ///
	l.hdd l.cdd l.lnresi_qpc1 l.year) replace dfe cluster(id)
	estimates store v6
		
use data/legacy_utility_data_controls, clear
bysort id: egen minmmiles=min(mmiles)
xtset id year
keep if portion_resi_sales>=.9 ///
	& abs(d.lnresi_cust1)<.2 & abs(d.lncomm_cust1)<.5 ///
	& regime_length>=2 ///
	& abs(dlncomm_nr1)<2 ///
	& comm_nrpc1<`comm_nrpc1limit' & comm_nrpq1<`comm_nrpq1limit' 
reg dlncomm_nr1 ///
	dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	d.hdd d.cdd d.lncomm_qpc1 ///
	, cluster(id) 
	estimates store v7
areg lncomm_nr1 ///
	lncomm_grow1 lncomm_shrink1 comm_dummy_grow_1 ///
	hdd cdd lncomm_qpc1 year ///
	, absorb(fe_regime) cluster(id) 
	estimates store v8
xtset fe_regime year
xtpmg d.lncomm_nr1 dlncomm_grow1 dlncomm_shrink1 comm_dummy_grow_1 ///
	d.hdd d.cdd d.lncomm_qpc1 year, ///
	lr(l.lncomm_nr1 l.lncomm_grow1 l.lncomm_shrink1 l.comm_dummy_grow_1 ///
	l.hdd l.cdd l.lncomm_qpc1 l.year) replace dfe cluster(id)
	estimates store v9
	
esttab v1 v2 v3 v4 v5 v6 v7 v8 v9 ///
	using vecmmiles.tex, replace fragment ///
 	cells(b(fmt(%12.3f) star) se(par fmt(%12.3f)))	///
	stats(N, fmt(%9.0fc) ///
		labels("Observations" ))	///
	mlabel("Miles (log)" "Miles (log)") ///
	label lz varwidth(16) modelwidth(13) style(tex) ///
	posthead("\\ \hline \\") prefoot("\\ \hline \\") ///
	collabels(,none) nonumbers	///
	coeflabels(_cons "Constant") /// 
	starlevels(* 0.1 ** 0.05 *** 0.01)
	
	
			
